package com.longrise.android.byjk.plugins.hra.hratabthird;

import com.longrise.LEAP.Base.Objects.EntityBean;
import com.longrise.android.byjk.common.UrlConstants;
import com.longrise.android.byjk.model.UserInfor;
import com.longrise.android.loaddata.newloaddata.LoadDataManagerFather;
import com.longrise.common.datasource.remote.LoadDataManager;

/**
 * Created by Administrator on 2018/1/3.
 */

public class MineEndorsePresenter extends MineEndorseContract.Presenter  {


    @Override
    protected void init() {

    }

    //获取我的改签列表页
    @Override
    public void getEndorseList() {
        String usersfzh = UserInfor.getInstance().getUsersfzh();
        EntityBean bean = new EntityBean();
        bean.set("paycardno", usersfzh);
        EntityBean bean1 = new EntityBean();
        bean1.set("bean", bean);
        LoadDataManager.getInstance().callService2(null, UrlConstants.BaseUrl, "hra_getMyEndorseList", bean1, new LoadDataManager.OnRequestCallListener2() {

            @Override
            public void onSuccess(String key, String service, Object result) {
                try {
                    EntityBean bean = (EntityBean) result;
                    mView.refreshData(bean);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }


            @Override
            public void onFinished(String key, String service) {
                mView.setRefreshing(false);
            }

            @Override
            public void onError(String key, String service, LoadDataManagerFather.ResultType resultType) {

            }

        });
    }

    //获取搜索我的改签用户信息
    @Override
    public void getSearchEndorse(String username) {
        String usersfzh = UserInfor.getInstance().getUsersfzh();
        EntityBean bean = new EntityBean();
        bean.set("paycardno", usersfzh);
        bean.set("username", username);
        EntityBean bean1 = new EntityBean();
        bean1.set("bean", bean);
        LoadDataManager.getInstance().callService2(null, UrlConstants.BaseUrl, "hra_searchMyEndorse", bean1, new LoadDataManager.OnRequestCallListener2() {

            @Override
            public void onSuccess(String key, String service, Object result) {
                try {
                    EntityBean bean = (EntityBean) result;
                    mView.refreshData(bean);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }


            @Override
            public void onFinished(String key, String service) {
                mView.setRefreshing(false);
            }

            @Override
            public void onError(String key, String service, LoadDataManagerFather.ResultType resultType) {

            }

        });
    }
}
